<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 继承 -> 子承父业(继承已有的东西)

    // 面向对象的继承
    // 让一个类(构造函数) 继承 另一个类(构造函数) 的属性和方法,还可以定义,追加,修改自己的方法

    // 被继承的类 => 父类
    // 继承的类 => 子类

    // 继承的目的: 实现代码的复用 (构造函数中的实例化对象相关, 原型对象相关)

    function Person(name, age) {
        this.name = name;
        this.age = age;
    }

    Person.prototype.species = "human";
    Person.prototype.skill = function () {
        console.log("thinking");
    }
    Person.prototype.say = function () {
        console.log(this.name, this.age);
    }

    // var p = new Person("张三", 18);
    // console.log(p);


    function YellowPerson(name, age, hobby) {
        // this.name = name;
        // this.age = age;
        this.hobby = hobby;
    }

    // YellowPerson.prototype.species = "human";
    // YellowPerson.prototype.skill = function () {
    //     console.log("thinking");
    // }
    // YellowPerson.prototype.say = function () {
    //     console.log(this.name, this.age);
    // }
    YellowPerson.prototype.speak = function () {
        console.log("chinese");
    }
</script>

</html>